﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Configuration;
using AccountingClient.Properties;

namespace AccountingClient
{
    public partial class LoginDialog : XtraForm
    {
        public LoginDialog()
        {
            InitializeComponent();
            foreach (var item in Settings.Default.Endpoints)
            {
                txtAddress.Items.Add(item);
            }
        }

        private void LoginDialog_Load(object sender, EventArgs e)
        {

        }

        public string UserName { get { return txtUserName.Text; } set { txtUserName.Text = value; } }

        public string Password { get { return txtPassword.Text; } set { txtPassword.Text = value; } }

        public string Address { get { return txtAddress.Text; } set { txtAddress.Text = value; } }

        public bool getLogin()
        {
            return this.ShowDialog() == DialogResult.OK;
        }

        private void txtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnOK.PerformClick();
            }
        }

        private void txtUserName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                txtPassword.Focus();
            }
        }

        private void LoginDialog_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                btnCancel.PerformClick();
            }
        }
    }
}
